﻿using System;

namespace Geometry
{
    /// <summary>
    /// 链拓扑
    /// </summary>
    public class LineStringDIME : LineString
    {
        #region 字段属性
        public string LefthPolygonID { get; set; }
        public string RightPolygonID { get; set; }
        #endregion

        #region 构造器
        public LineStringDIME(string id,
             string lPolygonID, string rPolygonID)
        {
            this.id = id;
            RightPolygonID = rPolygonID;
            LefthPolygonID = lPolygonID;
        }

        public LineStringDIME() { }
        #endregion

        #region 方法
        public new void WriteLine()
        {
            Console.Write($"{ID}\t\t{LefthPolygonID}" +
                $"\t\t{RightPolygonID}\t\t(");
            for (int i = 0; i < PointIDList.Count; i++)
            {
                if (i != PointIDList.Count - 1)
                    Console.Write($"{PointIDList[i]},");
                else
                    Console.Write($"{PointIDList[i]})\n");
            }
        }

        public string GetContactPolygon(string polygonID)
        {
            if (LefthPolygonID == polygonID)
                return RightPolygonID;
            else if (RightPolygonID == polygonID)
                return LefthPolygonID;
            else
                return string.Empty;
        }
        #endregion
    }
}
